<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html">
<ui:composition template="/WEB-INF/views/oneColumnBody.xhtml">
    <f:loadBundle var="msg" basename="pl.pawluk.inz.web.SpringResourceBundle"/>
    <ui:define name="editDialogForm"> <ui:include src="editCourse.xhtml"/></ui:define>
    <ui:define name="center_content">
        <h:form id="listForm" prependId="true">
            <div class="title_welcome"><h:outputText value="#{msg.coursesList}"/></div>
            <div class="features">
                <div class="title"></div>
                <p:toolbar id="editToolbar">
                    <p:toolbarGroup align="left">
                        <p:commandButton value="New" icon="ui-icon-document" actionListener="#{coursesBean.createNew}"
                                         update=":editForm:editPanel" oncomplete="eDialog.show()"/>
                        <p:separator/>
                        <p:commandButton title="Delete" icon="ui-icon-trash"
                                         disabled="#{coursesBean.course.name == null}"
                                         actionListener="#{coursesBean.delete}"
                                         update=":listForm:editTable :gf:growl"/>
                        <p:commandButton type="button" title="Edit" icon="ui-icon-pencil"
                                         disabled="#{coursesBean.course.name == null}"
                                         onclick="eDialog.show();"/>
                        <p:separator/>
                        <p:commandButton title="Refresh" icon="ui-icon-refresh" update=":listForm:editTable"/>
                        <p:separator/>
                    </p:toolbarGroup>
                </p:toolbar>
                <p:dataTable id="editTable" var="course" value="#{coursesBean.courses}" scrollable="true"
                             scrollHeight="150"
                             selection="#{coursesBean.course}" selectionMode="single" rowKey="#{course.id}">
                    <p:ajax event="rowSelect" update=":editForm:editPanel :listForm:editToolbar"
                            listener="#{coursesBean.onRowSelect}"/>
                    <p:ajax event="rowUnselect" listener="#{coursesBean.onRowUnselect}"
                            update=":editForm:editPanel :listForm:editToolbar"/>
                    <p:column headerText="#{msg.courseName}">
                        <h:outputText value="#{course.name}"/>
                    </p:column>

                    <p:column headerText="#{msg.courseStart}">
                        <h:outputText value="#{course.start}"/>
                    </p:column>

                    <p:column headerText="#{msg.courseStop}">
                        <h:outputText value="#{course.stop}"/>
                    </p:column>
                </p:dataTable>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
</html>